package com.m7788.util;

import android.content.Context;
import android.webkit.JsPromptResult;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebView;

public class HtmlChromeClient extends WebChromeClient {
	private Context context;
	OnProgressChangedListener onProgressChangedListener;
	public HtmlChromeClient(Context context,OnProgressChangedListener act) {
		this.context = context;
		this.onProgressChangedListener = act;
	}
	
  
	
	@Override
	public void onProgressChanged(WebView view, int newProgress) {
		// TODO Auto-generated method stub
		super.onProgressChanged(view, newProgress);
		onProgressChangedListener.onProgressChanged(newProgress);
	
	}
	public interface OnProgressChangedListener{
		public void onProgressChanged(int newProgress);
		}


	@Override
	public boolean onJsAlert(WebView view, String url, String message,
			final JsResult result) {
//		AlertDialog.Builder b2 = new AlertDialog.Builder(context)
//        .setTitle("").setMessage(message)
//        .setPositiveButton("ok",
//                new AlertDialog.OnClickListener() {
//                    @Override
//                    public void onClick(DialogInterface dialog,
//                            int which) {
//                        result.confirm();
//                    }
//
//                });
//		
//		b2.setCancelable(false);
//		b2.create();
//		b2.show();
//		return true;
		return super.onJsAlert(view, url, message, result);
	}

	@Override
	public boolean onJsConfirm(WebView view, String url, String message,
			JsResult result) {
		// TODO Auto-generated method stub
		return super.onJsConfirm(view, url, message, result);
	}

	@Override
	public boolean onJsPrompt(WebView view, String url, String message,
			String defaultValue, JsPromptResult result) {
		// TODO Auto-generated method stub
		return super.onJsPrompt(view, url, message, defaultValue, result);
	}

}
